import http from "../../utils/axios";

// 添加管理员
export const createAdminAPI = (data: any) => {
  const { account, ...identity } = data;
  return http<any, any>({
    url: "/user/createAdmin",
    method: "POST",
    data: {
      account,
      ...identity,
    },
  });
};
// 获取管理员列表
export const getAdminListAPI = (identity: string) =>
  http<any, any>({
    url: "/user/getAdminList",
    method: "POST",
    data: {
      identity,
    },
  });
// 获取部门筛选列表
export const getDepartmentListAPI = (department: string) =>
  http<any, any>({
    url: "/user/getDepartmentList",
    method: "POST",
    data: {
      department,
    },
  });
// 编辑管理员账户信息
export const editorAdminAPI = (data: any) => {
  const { id, ...department } = data;
  return http<any, any>({
    url: "/user/editorAdmin",
    method: "POST",
    data: {
      id,
      ...department,
    },
  });
};
// 对管理员取消赋权
export const changeIdentityToUserAPI = (id: number) =>
  http<any, any>({
    url: "/user/changeIdentityToUser",
    method: "POST",
    data: {
      id,
    },
  });
// 对管理员进行赋权
export const changeIdentityToAdminAPI = (id: number, identity: any) =>
  http<any, any>({
    url: "/user/changeIdentityToAdmin",
    method: "POST",
    data: {
      id,
      identity,
    },
  });
// 通过账号对用户搜索
export const searchUserAPI = (account: string, identity?: string) =>
  http<any, any>({
    url: "/user/searchUser",
    method: "POST",
    data: {
      account,
      identity,
    },
  });
// 冻结用户
export const banUserAPI = (id: number) =>
  http<any, any>({
    url: "/user/banUser",
    method: "POST",
    data: {
      id,
    },
  });
// 解冻用户
export const hotUserAPI = (id: number) =>
  http<any, any>({
    url: "/user/hotUser",
    method: "POST",
    data: {
      id,
    },
  });
// 获取用户冻结列表
export const getBanListAPI = () =>
  http<any, any>({
    url: "/user/getBanList",
    method: "POST",
  });
// 删除用户
export const deleteUserAPI = (id: number, account: string) =>
  http<any, any>({
    url: "/user/deleteUser",
    method: "POST",
    data: {
      id,
      account,
    },
  });
// 修改密码
export const changePasswordAPI = (data:any) =>
  http<any, any>({
    url: "/user/changePassword",
    method: "POST",
    data: data
  });
